package com.example.work_study_system.web.controller;


import com.example.work_study_system.model.domain.Student;
import com.example.work_study_system.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    @GetMapping("/list")
    public List<Student> list() {
        return studentService.list();
    }

    @GetMapping("/{id}")
    public Student getById(@PathVariable Integer id) {
        return studentService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Student student) {
        return studentService.save(student);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Student student) {
        return studentService.updateById(student);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return studentService.removeById(id);
    }
} 